Skip to content

Conversation

@wxtim
Copy link
Member

@wxtim wxtim commented Jun 2, 2025

Closes #6771

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@wxtim wxtim force-pushed the fix.validate-fail-if-xtriggers-or branch from 93f5936 to a3561d3 Compare June 2, 2025 09:42
@wxtim wxtim self-assigned this Jun 2, 2025
@wxtim wxtim added bug Something is wrong :( small labels Jun 2, 2025
@wxtim wxtim requested review from MetRonnie and hjoliver June 2, 2025 09:43
@MetRonnie MetRonnie changed the title ensure that xtrigger or fails Ensure that xtrigger OR fails validation Jun 4, 2025
@oliver-sanders oliver-sanders added this to the 8.4.3 milestone Jun 11, 2025
@oliver-sanders oliver-sanders marked this pull request as draft June 11, 2025 12:27
@oliver-sanders oliver-sanders linked an issue Jun 11, 2025 that may be closed by this pull request
@oliver-sanders oliver-sanders modified the milestones: 8.4.3, 8.4.x Jun 17, 2025
@MetRonnie MetRonnie removed their request for review July 21, 2025 17:07
@wxtim wxtim force-pushed the fix.validate-fail-if-xtriggers-or branch from 4013771 to 6845de6 Compare August 14, 2025 14:46
@wxtim wxtim changed the base branch from 8.4.x to 8.5.x August 14, 2025 14:49
@wxtim wxtim force-pushed the fix.validate-fail-if-xtriggers-or branch from 6845de6 to c9f1d34 Compare August 26, 2025 14:45
@wxtim wxtim marked this pull request as ready for review August 26, 2025 15:01
@hjoliver
Copy link
Member

hjoliver commented Aug 27, 2025

This fails here and on master, but I wonder if it needs to?

@x & (a | b) => c
$ cylc val .
WorkflowConfigError: Xtriggers cannot be used in conditional graph expressions:
@x&(a:succeeded|b:succeeded) => c

It's been a long time since I looked at - and probably wrote - the associated code, so I'm not sure of the reason for the restriction anymore, and whether it should apply to this sort of expression (and I'm out of time today). But possibly it should not fail because it's equivalent to this:

@x => c
a | b => c

@wxtim wxtim requested a review from oliver-sanders August 27, 2025 08:12
@oliver-sanders
Copy link
Member

oliver-sanders commented Aug 29, 2025

This fails here and on master, but I wonder if it needs to?

If this PR isn't changing behaviour, suggest moving this to another issue. Opened #6949.

@oliver-sanders
Copy link
Member

oliver-sanders commented Aug 29, 2025

As Hillary pointed out, there is already logic intended to catch xtriggers used in conditional expressions:

# force trigger evaluation now
try:
itask.state.prerequisites_eval_all()
except TriggerExpressionError as exc:
err = str(exc)
if '@' in err:
print(
f"ERROR, {name}: xtriggers can't be in conditional"
f" expressions: {err}",
file=sys.stderr,
)
else:
print(
'ERROR, %s: bad trigger: %s' % (name, err), file=sys.stderr
)

However, this check isn't catching situations where there are no tasks on the LHS, only xtriggers.

Sidenote: Strangely, this code is in cylc.flow.validate (which means you can bypass this error using cylc install; cylc play). I suspect this is purely historical, this should really be in cylc.flow.config.

If the new test covers all of the logic of the old one, suggest ripping the old check out. There are probably tests for the old check which could do with being combined / erased.

@oliver-sanders
Copy link
Member

I ran a bunch of our workflows through cylc validate on this branch, no spurious failures :)

However, beyond @wall_clock xtriggers are not used at our site, might be worth getting Hillary to make sure it doesn't cause any false positives with NIWA workflows?

@hjoliver
Copy link
Member

However, beyond @wall_clock xtriggers are not used at our site, might be worth getting Hillary to make sure it doesn't cause any false positives with NIWA workflows?

Unfortunately, due to enforced home dir privacy here, I can't see our workflows.

@wxtim wxtim marked this pull request as draft September 1, 2025 09:05
@MetRonnie MetRonnie modified the milestones: 8.4.x, 8.5.x Sep 3, 2025
@oliver-sanders oliver-sanders modified the milestones: 8.5.x, 8.6.x Oct 2, 2025
@oliver-sanders oliver-sanders changed the base branch from 8.5.x to 8.6.x October 2, 2025 08:50
@wxtim wxtim marked this pull request as ready for review October 16, 2025 14:03
@oliver-sanders
Copy link
Member

oliver-sanders commented Oct 23, 2025

@wxtim, I think the reason you drafted this is that there is already code that is supposed to detect this scenario, but it's not working right, see #6772 (comment).

We only need one check, but would like it to cover all bases.

Removing (or fixing) the other check would probably resolve the situation where this expression is failing validation:

@x & (a | b) => c

Not strictly the job of this PR, but these two approaches have to be rationalised anyway (see #6772 (comment))

@wxtim wxtim marked this pull request as draft October 30, 2025 10:22
# * the expression is constructed internally
# * https://github.com/cylc/cylc-flow/issues/4403
except (SyntaxError, ValueError) as exc:
err_msg = str(exc)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 3.10 Python no longer emits the message being searched for here. ref

@wxtim
Copy link
Member Author

wxtim commented Oct 30, 2025

If the new test covers all of the logic of the old one, suggest ripping the old check out.

Done that

There are probably tests for the old check which could do with being combined / erased.

I couldn't find any and nothing failed when I took it out.
🤣🤣🤣🤣

I have added a unit test for some of the remaining untested stuff. I'm not entirely convinced that it's reachable.

@wxtim wxtim requested a review from MetRonnie October 30, 2025 14:24
@wxtim wxtim marked this pull request as ready for review October 30, 2025 14:24
@wxtim wxtim force-pushed the fix.validate-fail-if-xtriggers-or branch from 9b2acf7 to 68a4d07 Compare October 30, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is wrong :( small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xtrigger OR doesn't fail validation

5 participants